import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class PasswordDebug {
    public static void main(String[] args) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        
        // 测试常见的密码
        String[] passwords = {"admin123", "123456", "admin", "password"};
        
        // 常见的admin密码哈希
        String[] hashes = {
            "$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2", // 原始SQL中的
            "$2a$10$7JB720yubVSNvJF7b0J.LOn5LgT89CJpJTXOu3DEK0TJoXRCb2EGO", // fixed SQL中的
            "$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHsM8lE9P4G5jgggdfcDWu"  // 我们生成的admin123
        };
        
        System.out.println("=== 密码匹配测试 ===");
        
        for (int i = 0; i < hashes.length; i++) {
            System.out.println("\n哈希 " + (i+1) + ": " + hashes[i]);
            for (String password : passwords) {
                boolean matches = encoder.matches(password, hashes[i]);
                System.out.println("  密码 '" + password + "': " + (matches ? "✓ 匹配" : "✗ 不匹配"));
            }
        }
        
        // 生成新的admin123哈希用于测试
        System.out.println("\n=== 生成新的admin123哈希 ===");
        String newHash = encoder.encode("admin123");
        System.out.println("新哈希: " + newHash);
        System.out.println("验证admin123: " + encoder.matches("admin123", newHash));
    }
} 